function getCookie(name) {
    var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
    return r ? r[1] : undefined;
}

// 提取地址栏中的查询字符串
function get_query_string(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return decodeURI(r[2]);
    }
    return null;
}

$("#btn_success").click(function () {
    var order_id = get_query_string('order_id');
    var url = '/payment/' + order_id + '/';
    $.ajax({
        url: url,
        type: "GET",
        responseType: 'json',
        success: function (data) {
            if (data.code == "0") {
                // 跳转到支付宝
                window.location.href = data.alipay_url;
            } else {
                alert(data.errmsg)
            }
        }
    });
});
